package com.example.demo.design.mode.singleton;

/**
 * @Classname StaticInnerSingleton
 * @Description  静态内部类（Static Inner Class）：
 *                   这种方式利用了 Java 的类加载机制，实现了线程安全且只创建一个实例的单例模式。
 *
 *
 * @Date 2023/11/28 10:00
 * @Created by jyl
 */
public class StaticInnerSingleton {

    private StaticInnerSingleton() {}

    private static class SingletonHolder {
        private static final StaticInnerSingleton INSTANCE = new StaticInnerSingleton();
    }

    public static StaticInnerSingleton getInstance() {
        return SingletonHolder.INSTANCE;
    }

}
